<?php

/* @var $this yii\web\View */
use yii\helpers\Html;
use yii\grid\GridView;
use app\models\ChargeCashDeal;
use yii\data\ActiveDataProvider;

$dataProvider = new ActiveDataProvider([
    'query' => ChargeCashDeal::find()->select(['id','orderno','money','status','member_id','reg_dt'])->where(
      [
        'type' => ChargeCashDeal::TYPE_CHARGE,
        'member_id'=>Yii::$app->user->getId()
      ])->with('member'),
    'pagination' => [
        'pageSize' => 20,
    ],
]);

$this->title = '充值记录';
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="page-title">
  <div>
    <h1><i class="fa fa-money"></i> 充值记录</h1>
  </div>
</div>

    <div class="card">
      <?php
      //如何提前加载资源
echo GridView::widget([
    'dataProvider' => $dataProvider,
    'columns' => [
    [
      'class' => 'yii\grid\SerialColumn',
      'header' => '序号'
    ],
    [
      'header'=>'订单号',
      'content'=>function($model,$key,$index,$column){
        return $model->orderno;
      }
    ],
    [
      'header'=>'充值时间',
      'content'=>function($model,$key,$index,$column){
        $output=Yii::$app->formatter->asDate($model->reg_dt,'yyyy-MM-dd');
        return $output;
      }
    ],
    [
      'header'=>'充值金额',
      'content'=>function ($model, $key, $index, $column) {
          return number_format($model->money,2);
      },
    ],
    [
        'header'=>'状态',
        'content'=>function($model, $key, $index, $column)
        {
          switch($model->status){
            case ChargeCashDeal::STATUS_REGISTER:
            return '<i class="fa fa-hourglass-half"></i> 正在审核';
            case ChargeCashDeal::STATUS_PROVED:
            return '<i class="fa fa-check-circle alert-info"></i> 成功';
            case ChargeCashDeal::STATUS_UNPROVED:
            return '<i class="fa fa-times-circle alert-danger"></i> 失败';
            case ChargeCashDeal::STATUS_DISCARD:
            return '<i class="fa fa-trash alert-default"></i> 作废';
            default:
            return '<i class="fa fa-trash alert-default"></i> 作废';
          }
        }
    ],
],

]);
?>
</div>
